package index

import (
	"time"

	"gitee.com/zhenyangze/gin-framework/internal/app/middleware"
	"gitee.com/zhenyangze/gin-framework/internal/app/middleware/persistence"
	limit "github.com/aviddiviner/gin-limit"
	"github.com/gin-gonic/gin"
)

func Router(router *gin.Engine) {
	store := &persistence.RedisStore{}
	v1 := router.Group("/v1", limit.MaxAllowed(20))
	{
		v1.GET("/test", TestHandle)
		v1.GET("/view/:name/*action", ViewHandle)
		v1.GET("/view", ViewHandle)
		v1.POST("/valid", ValidHandle)
		v1.GET("/ormmiddle", middleware.CachePage(store, time.Minute, OrmHandle))
		v1.GET("/ormcache", OrmWithCacheHandle)
		v1.GET("/orm", OrmHandle)
		v1.GET("/redis", RedisHandle)
		v1.GET("/md5/:str", Md5Handle)
	}

	router.GET("/", MyHandle)

}
